<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>
<h2>事件对象作用</h2>
<input type="text" id="username" value="">
<script type="text/javascript">
 var it=document.getElementById('username');
it.onkeydown=function(evt){
    console.log(evt.keyCode);
}
</script>
</body>
</html>